// Package domain
// Created by GoLand
// @User: lenora
// @Date: 2024/1/18
// @Time: 12:44

package domain

import (
	intrv1 "camp/microbook/api/proto/gen/interactive"
	"time"
)

type Article struct {
	Id       uint64        `json:"id,omitempty"`
	Title    string        `json:"title,omitempty"`
	Abstract string        `json:"abstract,omitempty"`
	Content  string        `json:"content,omitempty"`
	Author   Author        `json:"author,omitempty"`
	Status   ArticleStatus `json:"status,omitempty"`
	Utime    time.Time     `json:"utime"`
	*intrv1.Interactive
}

func (a *Article) Abstraction() string {
	str := []rune(a.Content)
	if len(str) > 128 {
		str = str[:128]
	}
	return string(str)
}

type ArticleStatus uint8

func (s ArticleStatus) ToUint8() uint8 {
	return uint8(s)
}

const (
	//StatusUnknown 未知状态
	StatusUnknown = iota
	//StatusUnpublished 未发表
	StatusUnpublished
	//StatusPublished 已发表
	StatusPublished
	//StatusPrivate 仅自己可见
	StatusPrivate
)

type Author struct {
	Id   uint64
	Name string
}
